/**
 * LinkedLST
 * May 26, 2011
 * CommonHandlers.java - A collection of common handlers used in many activities.
 */

package edu.washington.cs.labspecimentransport.ops;

import java.util.ArrayList;

import edu.washington.cs.labspecimentransport.HomeView;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

/**
 * A collection of common handlers used in many activities.
 */
public class CommonHandlers {
	
	private CommonHandlers() {};
	
    /** Returns to the home screen. */
    public static void returnHome(Activity activity) {
    	Intent i = new Intent(activity, HomeView.class);
    	Bundle b = new Bundle();
    	
    	// reset any existing scan session
    	b.putSerializable(Keys.KEY_SCANNEDITEMS, new ArrayList<String>());
    	
    	b.putAll(activity.getIntent().getExtras());
		i.putExtras(b);
		activity.startActivity(i);
    }
	
    /** Open a web browser and navigate to our help page */
	public static void startHelp(Context context) {
		String url = Settings.helpURL;
		Intent i = new Intent(Intent.ACTION_VIEW);
		i.setData(Uri.parse(url));
		context.startActivity(i);
	}

}
